package com.tenoz.display
{
	import flash.display.Bitmap;
	import flash.display.Loader;
	import flash.display.Sprite;
	import flash.geom.ColorTransform;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;

	public class MenuItem extends Sprite
	{
		public var textfield:TextField;
		public var bg:Sprite;
		public var type:String;
		public var id:String;
		public var loader:Loader;
		public var mapPoints:Array;
		public var icon:Bitmap;
		public var link_url:String;
		public var target:String;
		private var _toggle:Boolean = false;
		
		public function get toggle():Boolean { return _toggle; }
		public function set toggle(b:Boolean):void
		{
			_toggle = b;
		}
		
		public function MenuItem()
		{
			this.mouseChildren = false;
		}
		
		override public function set width(value:Number):void
		{
			bg.width = value;
		}
		
		public function setTitle(str:String):void
		{
			textfield.text = str;
			textfield.autoSize = TextFieldAutoSize.LEFT;
			this.width = textfield.x + textfield.width + 11;
		}
		
		public function setColor(color:uint):void
		{
			var blue:int = 0xFF & color;
			var green:int = 0xFF & (color >> 8);
			var red:int = 0xFF & (color >> 16);

			bg.transform.colorTransform = new ColorTransform(0,0,0,0,red,green,blue,0xFF);
		}
		
		override public function toString():String
		{
			var str:String = "[MenuItem ID: "+this.id+", Title:"+this.textfield.text+", Type:"+this.type+"]";
			return str;
		}
	}
}